package com.scuec.trainingmanagementsys.service.impl;
import com.scuec.trainingmanagementsys.entity.Assessment;
import com.scuec.trainingmanagementsys.mapper.AssessmentMapper;
import com.scuec.trainingmanagementsys.service.AssessmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class AssessmentServiceImpl implements AssessmentService {
    @Autowired
    private AssessmentMapper assessmentMapper;

    @Override
    public int addAssessment(Assessment assessment) {
        if (assessment.getAsCreateTime() == null) {
            assessment.setAsCreateTime(new Date());
        }
        return assessmentMapper.addAssessment(assessment);
    }

    @Override
    public int deleteAssessmentById(Integer assessmentID) {
        return assessmentMapper.deleteAssessmentById(assessmentID);
    }

    @Override
    public Assessment findAssessmentById(Integer assessmentID) {
        return assessmentMapper.findAssessmentById(assessmentID);
    }

    @Override
    public List<Assessment> findAllAssessments() {
        return assessmentMapper.findAllAssessments();
    }

    @Override
    public List<Assessment> findAssessmentsByTeacherId(Integer teacherID) {
        return assessmentMapper.findAssessmentsByTeacherId(teacherID);
    }

    @Override
    public int updateAssessment(Assessment assessment) {
        return assessmentMapper.updateAssessment(assessment);
    }

    @Override
    public List<Assessment> findAssessmentsByDailyReportID(Integer dailyReportID) {
        return assessmentMapper.findAssessmentsByDailyReportID(dailyReportID);
    }

    @Override
    public List<Map<String, Object>> findAssessmentsByDailyReportIDWithDetails(Integer dailyReportID) {
        return assessmentMapper.findAssessmentsByDailyReportIDWithDetails(dailyReportID);
    }
}
